package com.pt25.service.sys.interfaces.facade.inner;


import com.pt25.base.model.websocket.WebsocketHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@Tag(name = "msg inner api")
@RestController
@RequestMapping("/inner-api/sys")
public class MsgInnerController implements WebsocketHandler {


    @Override
    public void handleTextMessage(ChannelHandlerContext ctx, TextWebSocketFrame msg) {
        log.info("收到msg:{}", msg.text());
        ctx.writeAndFlush(new TextWebSocketFrame("hello client friend!"));
    }

    @Override
    public void handleBinaryMessage(ChannelHandlerContext channelHandlerContext, BinaryWebSocketFrame binaryWebSocketFrame) {

    }

    @Override
    public void handleErrorMessage(ChannelHandlerContext ctx, Throwable cause) {

    }

    @Override
    public void handleChannelActive(ChannelHandlerContext ctx) {

    }

    @Override
    public void handleChannelInactive(ChannelHandlerContext ctx) {

    }

    @Override
    public Boolean checkAuthorization(ChannelHandlerContext ctx, FullHttpRequest request) {
        return true;
    }

    @Override
    public void handleHeartbeat(ChannelHandlerContext ctx, Integer status) {

    }

}
